/**
 * @description 裁剪字符串长度
 *
 * @param {string} text 需要裁剪的字符串
 *      例: HelloWorld
 * @param {number} length 需要保留的长度
 *      例: 5
 * @return {string}
 *      例：Hello
 * */
type CropTextDefine = (text: string, length: number) => string

const cropText: CropTextDefine = (text, length) => (text.length >= length ? `${text.substring(0, length)}...` : text)

export default cropText
